/*
 * @Author: zi.yang
 * @Date: 2021-10-02 13:39:27
 * @LastEditors: zi.yang
 * @LastEditTime: 2021-10-09 08:47:38
 * @Description: In User Settings Edit
 * @FilePath: \one.pm\src\store\User\mutations.js
 */
import * as auth from '@/Utils/auth'

export default {
  SET_TOKEN: (state, token) => {
    auth.setToken(token)
    state.token = token
  },
  DEL_TOKEN: (state) => {
    auth.removeToken()
    state.token = null
  },
  SET_LOGIN_TIME: (state, loginTime) => {
    state.loginTime = loginTime
  },
  SET_USER_INFO: (state, userinfo) => {
    state.userinfo = userinfo
  },
  DEL_USER_INFO: (state) => {
    state.userinfo = Object.create(null)
  },
  SET_USER_LIST: (state, userList) => {
    state.userList = userList
  },
  DEL_USER_IN_LIST: (state, userId) => {
    const index = state.userList.findIndex(user => user.id === userId)
    state.userList.splice(index, 1)
  }
}
